package com.gitee.springioc.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;

import java.util.Iterator;

/**
 * @author ming.yan-1
 * @version V1.0
 * @Title com.gitee.springioc.service.impl
 * @Description
 * @date 2018/9/16  上午10:43
 */
public class OrderBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor {

    private static final Log logger = LogFactory.getLog(OrderBeanFactoryPostProcessor.class);

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
        BeanDefinition beanDefinition = beanDefinitionRegistry.getBeanDefinition("OrderService");
        logger.info("into OrderBeanDefinitionRegistryPostProcessor postProcessBeanDefinitionRegistry method");
        beanDefinitionRegistry.registerBeanDefinition("CodeRegist", new RootBeanDefinition(CodeRegistImpl.class));
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        Iterator<String> iterator = configurableListableBeanFactory.getBeanNamesIterator();
        logger.info("into OrderBeanDefinitionRegistryPostProcessor postProcessBeanFactory method");
    }

}
